package com.csyf.manager.config;

import com.csyf.manager.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @Author: Enzo
 * @Date: 2018/3/29 13:02
 */
@Configuration
public class WebAppConfig extends WebMvcConfigurerAdapter {


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        super.addInterceptors(registry);
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/sys/**")
                .addPathPatterns("/boss/**")
                .addPathPatterns("/boss/view/**")
                .addPathPatterns("/view/**")
                .excludePathPatterns(
                        "/api/**",
                        "/sys/login",
                        "/sys/user_login",
                        "/sys/sms/sendLoginVerifyCode",
                        "/boss/",
                        "/boss/boss_login"
                        );
        super.addInterceptors(registry);


    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //将所有/static/** 访问都映射到classpath:/static/ 目录下
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
    }
}
